package com.gqh.weather.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gqh.weather.domain.entity.City;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description 城市区域管理数据访问接口
 * @author AI
 * @date 2025-09-21
 */
@Mapper
public interface CityMapper extends BaseMapper<City> {

    @Select("select * from sys_area where code = #{code}")
    City selectByCode(String code);
    
    /**
     * 根据父ID查询所有子区域
     * 
     * @param pid 父ID
     * @return 子区域列表
     */
    @Select("select code from sys_area where pid = (select id from sys_area where code = #{code})")
    List<String> selectChildrenCodesByCode(@Param("code") String code);
    
}